package net.zhongfu.flowable.helper.dataType;

import liquibase.change.core.LoadDataChange;
import liquibase.database.Database;
import liquibase.datatype.DataTypeInfo;
import liquibase.datatype.DatabaseDataType;
import liquibase.datatype.LiquibaseDataType;
import liquibase.datatype.core.BooleanType;

@DataTypeInfo(name = "boolean", minParameters = 0, maxParameters = 1,
        priority = LiquibaseDataType.PRIORITY_DEFAULT, aliases = {"java.sql.Types.BOOLEAN", "java.lang.Boolean", "bit", "bool"})
public class BooleanDataTypeDm extends BooleanType {
    @Override
    public LoadDataChange.LOAD_DATA_TYPE getLoadTypeName() {
        return LoadDataChange.LOAD_DATA_TYPE.DATE;
    }

    @Override
    public String getRawDefinition() {
        return "INT";
    }

    @Override
    public Object[] getParameters() {
        return new Object[]{};
    }

    @Override
    public DatabaseDataType toDatabaseDataType(Database database) {
        return new DatabaseDataType("NUMBER",1);
    }

    @Override
    protected boolean isNumericBoolean(Database database) {
        return true;
    }

    @Override
    public String getFalseBooleanValue(Database database) {
        return "0";
    }

    @Override
    public String getTrueBooleanValue(Database database) {
        return "1";
    }
}
